Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@types/babel__traverse
Advanced tools
TypeScript definitions for @babel/traverse
The @types/babel__traverse package provides TypeScript type definitions for babel-traverse, which is a part of the Babel compiler. babel-traverse allows for navigating and updating the abstract syntax tree (AST) generated by Babel. This package is essential for TypeScript developers working with Babel, as it enables type checking and IntelliSense for babel-traverse functions and objects.
Visiting AST Nodes
This feature allows you to visit nodes in the AST and perform actions based on the type of node. The code sample demonstrates how to log the name of each identifier in the AST.
import traverse from '@babel/traverse';
import * as t from '@babel/types';
const ast = // some AST;
traverse(ast, {
enter(path) {
if (t.isIdentifier(path.node)) {
console.log('Found an identifier:', path.node.name);
}
}
});
Modifying AST Nodes
This feature enables the modification of nodes within the AST. In the provided code sample, every identifier named 'oldName' is renamed to 'newName'.
import traverse from '@babel/traverse';
import * as t from '@babel/types';
const ast = // some AST;
traverse(ast, {
enter(path) {
if (t.isIdentifier(path.node, { name: 'oldName' })) {
path.node.name = 'newName';
}
}
});
TypeScript is a superset of JavaScript that compiles to plain JavaScript and provides static typing. While not directly similar in functionality to @types/babel__traverse, TypeScript's compiler API allows for similar AST manipulation and traversal capabilities.
Recast is a JavaScript library for AST manipulation that allows you to parse, visit, and transform JavaScript code. It provides functionality similar to babel-traverse but focuses on preserving the original formatting of the code as much as possible.
jscodeshift is a toolkit for running codemods over multiple JavaScript or TypeScript files. It uses recast under the hood for parsing and printing but provides a higher-level API for transforming code. It's similar to babel-traverse in its ability to navigate and update ASTs but is more focused on large-scale codebase transformations.
npm install --save @types/babel__traverse
This package contains type definitions for @babel/traverse (https://github.com/babel/babel/tree/main/packages/babel-traverse).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel__traverse.
These definitions were written by Troy Gerwien, Marvin Hagemeister, Ryan Petrich, Melvin Groenhoff, Dean L., Ifiok Jr., ExE Boss, and Daniel Tschinder.
FAQs
TypeScript definitions for @babel/traverse
We found that @types/babel__traverse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.